package apiv1

import (
	"github.com/gin-gonic/gin"
	"go-shop-api/internal/service"
	"net/http"
)

//发送sms

// SendSms 发送sms 因为可以在未登录时被调用，所以写到pkg包里
func SendSms(c *gin.Context) {
	var SendSmsService *service.SendSmsService
	//绑定并验证
	if err := c.ShouldBind(&SendSmsService); err != nil {
		//返回验证器验证的错误信息
		c.JSON(http.StatusOK, Validators(err))
		return
	}

	res := SendSmsService.SendSms(c.Request.Context())
	c.JSON(http.StatusOK, res)
}

// CheckSms 检查短信
func CheckSms(c *gin.Context) {
	var checkSmsService service.CheckSmsService
	//绑定并验证
	if err := c.ShouldBind(&checkSmsService); err != nil {
		//返回验证器验证的错误信息
		c.JSON(http.StatusOK, Validators(err))
		return
	}
	res := checkSmsService.CheckSms(c.Request.Context())
	c.JSON(http.StatusOK, res)
}
